import jsMind from 'jsmind';

class Mind {
  mind = {
    meta: {
      name: 'demo',
      author: 'devui',
      version: '0.2',
    },
    format: 'node_array',
    data: [
      { id: 'root', isroot: true, topic: 'jsMind' },

      { id: 'sub1', parentid: 'root', topic: 'sub1', 'background-color': '#0000ff' },
      { id: 'sub11', parentid: 'sub1', topic: 'sub11' },
      { id: 'sub12', parentid: 'sub1', topic: 'sub12' },
      { id: 'sub13', parentid: 'sub1', topic: 'sub13' },

      { id: 'sub2', parentid: 'root', topic: 'sub2' },
      { id: 'sub21', parentid: 'sub2', topic: 'sub21' },
      { id: 'sub22', parentid: 'sub2', topic: 'sub22', 'foreground-color': '#33ff33' },

      { id: 'sub3', parentid: 'root', topic: 'sub3' },
    ]
  };

  constructor(container) {
    const jsMindContainer = typeof container === 'string' ? document.querySelector(container) : container;
    const options = {
      container: jsMindContainer,
      editable: true,
      theme: 'orange'
    };
    const jm = new jsMind(options);
    jm.show(this.mind);
  }
}

export default Mind;
